/*
title:Bellman-Ford 
*/

#include <iostream> 
using namespace std;
struct edge
{
	int v,u,w;
};
edge edges[200004];
int d[1004];
int maxDate=100000000;
int edgenum;

bool BellmanFord(int s)
{
	int i,j;
	bool flag=false;
	for(i=1;i<n+1;i++){
		flag=false;
		for(j=0;j<edgenum;j++){
			if(edges[j].u>d[edges[j].v]+edges[j]+w){
				flag=true;
				d[edges[j].u]=d[edges[j].v]+edges[j].w;
			}
		}
		if(!flag) break;
	}
	for(i=0;i<edgenum;i++){
		if(d[edges[i].v]<maxDate&&d[edges[i].u]>d[edges[i].v]+edges[i].w) return false;
	}
	return true;
}

int main()
{
	edgenum=0;
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>edges[i].v>>edges[i].u>>edges[i].w;
	}
	return 0;
}
